function show_add() {
	var formStore = new Ext.data.Store( [ 'Code', 'Name', 'Desc', 'parentID',
			'Win' ]);
	// var btn_value = Ext.ComponentMgr.get("get_btn").getValue();
	var deep = Ext.ComponentMgr.get("get_tree_deep").getValue();
	// if (btn_value == "新增流程域") {
	if (deep == "" || deep == "0") {
		var p_manage = new Ext.FormPanel( {
			labelWidth : 100,
			labelAlign : "left",
			layout : "form",
			region : "center",
			frame : true,
			items : [ {
				title : '新增流程域',
				layout : 'form',
				xtype : 'fieldset',
				collapsible : false,
				bodyStyle : 'padding: 10px 0 10px 0',
				labelAlign : 'right',
				height : '100%',
				width : '100%',
				items : [ {
					xtype : "textfield",
					fieldLabel : "流 程 域 编 码 ",
					allowBlank : false,
					id : 'domainCode',
					anchor : "88%",
					emptyText : '字母或下划线开头',
					regex : /^[A-Za-z_]+[A-Za-z0-9_]*$/
				}, {
					xtype : "textfield",
					fieldLabel : "流 程 域 名 称 ",
					emptyText : '请填写',
					blankText : '此项必填',
					allowBlank : false,
					anchor : "88%",
					id : 'domainName'
				}, {
					xtype : "textfield",
					fieldLabel : "流 程 域 描 述 ",
					anchor : "88%",
					id : 'domainDesc'
				} ]
			} ]
		})
	} else if (deep == "1") {
		// else if (btn_value == "新增流程") {

		var jReader1 = new Ext.data.JsonReader( {
			fields : [ {
				name : 'id'
			}, {
				name : 'text'
			} ]
		});
		var store = new Ext.data.Store(
				{
					autoLoad : true,
					url : basePath + 'JarpListener?className=cn.com.jsepc.rep.process.GetCombox&methodName=getDomain&paramCount=0',
					reader : jReader1

				});

		var comb_domainID = new Ext.form.ComboBox( {
			id : 'domainID',
			fieldLabel : "所 属 流 程 域  ",
			anchor : "88%",
			emptyText : '请选择(必选项)',
			blankText : '此项必选',
			editable : false,
			triggerAction : 'all',
			store : store,
			mode : 'remote',
			valueField : 'id',
			displayField : 'text'
		})

		// 流程
		var p_manage = new Ext.FormPanel( {
			labelWidth : 100,
			labelAlign : "left",
			layout : "form",
			region : "center",
			frame : true,
			items : [ {
				title : '新增流程',
				layout : 'form',
				xtype : 'fieldset',
				collapsible : false,
				bodyStyle : 'padding: 10px 0 10px 0',
				labelAlign : 'right',
				height : '100%',
				width : '100%',
				items : [ {
					xtype : "hidden",
					fieldLabel : "流 程 编 号 ",
					emptyText : '自动生成',
					disabled : true,
					id : 'processID',
					anchor : "88%"
				}, {
					xtype : "textfield",
					fieldLabel : "流 程 编 码 ",
					allowBlank : false,
					id : 'processCode',
					anchor : "88%",
					emptyText : '字母或下划线开头',
					regex : /^[A-Za-z_]+[A-Za-z0-9_]*$/
				}, {
					xtype : "textfield",
					fieldLabel : "流 程 名 称 ",
					emptyText : '请填写',
					blankText : '此项必填',
					allowBlank : false,
					anchor : "88%",
					id : 'processName'
				}, {
					xtype : "textfield",
					fieldLabel : "流 程 描 述 ",
					anchor : "88%",
					id : 'processDesc'
				}, {
					xtype : "hidden",
					fieldLabel : "所 属 流 程 域 ",
					anchor : "88%",
					id : 'domainID_hidden'
				}, [ comb_domainID ] ]
			} ]
		})
	} else if (deep == "2") {
		// else if(btn_value == "新增流程周期"){

		var jReader1 = new Ext.data.JsonReader( {
			fields : [ {
				name : 'id'
			}, {
				name : 'text'
			} ]
		});
		var store = new Ext.data.Store(
				{
					autoLoad : true,
					url : basePath + 'JarpListener?className=cn.com.jsepc.rep.process.GetCombox&methodName=getProcess&paramCount=0',
					reader : jReader1
				});

		var comb_process = new Ext.form.ComboBox( {
			id : 'processID',
			fieldLabel : "所 属 流 程 ",
			anchor : "88%",
			emptyText : '请选择(必选项)',
			blankText : '此项必选',
			editable : false,
			triggerAction : 'all',
			store : store,
			mode : 'remote',
			valueField : 'id',
			displayField : 'text'
		})
		var p_manage = new Ext.FormPanel( {
			labelWidth : 100,
			labelAlign : "left",
			layout : "form",
			region : "center",
			frame : true,
			items : [ {
				title : '新增流程周期',
				layout : 'form',
				xtype : 'fieldset',
				collapsible : false,
				bodyStyle : 'padding: 10px 0 10px 0',
				labelAlign : 'right',
				height : '100%',
				width : '100%',
				items : [ {
					xtype : "hidden",
					fieldLabel : "流程周期编号 ",
					emptyText : '自动生成',
					disabled : true,
					id : 'lifecycleID',
					anchor : "88%"
				}, {
					xtype : "textfield",
					fieldLabel : "流程周期编码 ",
					allowBlank : false,
					id : 'lifecycleCode',
					anchor : "88%",
					emptyText : '字母或下划线开头',
					regex : /^[A-Za-z_]+[A-Za-z0-9_]*$/
				}, {
					xtype : "textfield",
					fieldLabel : "流程周期名称 ",
					emptyText : '请填写',
					blankText : '此项必填',
					allowBlank : false,
					anchor : "88%",
					id : 'lifecycleName'
				}, {
					xtype : "textfield",
					fieldLabel : "流程周期描述 ",
					anchor : "88%",
					id : 'lifecycleDesc'
				}, {
					xtype : "hidden",
					fieldLabel : "所 属 流 程  ",
					anchor : "88%",
					id : 'processID_hidden'
				}, [ comb_process ] ]
			} ]
		})

	} else if (deep == "3") {
		// else if (btn_value == "新增环节") {// 环节

		var jReader1 = new Ext.data.JsonReader( {
			fields : [ {
				name : 'id'
			}, {
				name : 'text'
			} ]
		});
		var store = new Ext.data.Store(
				{
					autoLoad : true,
					url : basePath + 'JarpListener?className=cn.com.jsepc.rep.process.GetCombox&methodName=getLifecycle&paramCount=0',
					reader : jReader1

				});

		var comb_lifecycle = new Ext.form.ComboBox( {
			id : 'lifecycleID',
			fieldLabel : "所 属 流 程 ",
			anchor : "88%",
			emptyText : '请选择(必选项)',
			blankText : '此项必选',
			editable : false,
			triggerAction : 'all',
			store : store,
			mode : 'remote',
			valueField : 'id',
			displayField : 'text'
		})

		var p_manage = new Ext.FormPanel( {
			labelWidth : 100,
			labelAlign : "left",
			layout : "form",
			region : "center",
			frame : true,
			items : [ {
				title : '新增环节',
				layout : 'form',
				xtype : 'fieldset',
				bodyStyle : 'padding: 10px 0 10px 0',
				collapsible : false,
				labelAlign : 'right',
				height : '100%',
				width : '100%',
				items : [ {
					xtype : "hidden",
					fieldLabel : "环 节 编 号 ",
					emptyText : '自动生成',
					disabled : true,
					id : 'linkid',
					anchor : "88%"
				}, {
					xtype : "textfield",
					fieldLabel : "环 节 编 码 ",
					allowBlank : false,
					id : 'linkcode',
					anchor : "88%",
					emptyText : '字母或下划线开头',
					regex : /^[A-Za-z_]+[A-Za-z0-9_]*$/
				}, {
					xtype : "textfield",
					fieldLabel : "环 节 名 称 ",
					emptyText : '请填写',
					blankText : '此项必填',
					allowBlank : false,
					anchor : "88%",
					id : 'linkname'
				}, {
					xtype : "textfield",
					fieldLabel : "环 节 描 述 ",
					anchor : "88%",
					id : 'linkDesc'
				}, {
					xtype : "hidden",
					fieldLabel : "所属 流 程周期 ",
					anchor : "88%",
					id : 'lifecycleID_hidden'
				}, [ comb_lifecycle ] ]
			} ]
		})
	} else if (deep == "4") {// 关注点
	// } else if (btn_value == "新增关注点") {// 关注点
		var jReader1 = new Ext.data.JsonReader( {
			fields : [ {
				name : 'id'
			}, {
				name : 'text'
			} ]
		});
		var store = new Ext.data.Store(
				{
					autoLoad : true,
					url : basePath + 'JarpListener?className=cn.com.jsepc.rep.process.GetCombox&methodName=getLink&paramCount=0',
					reader : jReader1

				});
		var comb_link = new Ext.form.ComboBox( {
			id : 'linkID',
			fieldLabel : "所 属 环 节 ",
			anchor : "88%",
			emptyText : '请选择(必选项)',
			blankText : '此项必选',
			editable : false,
			triggerAction : 'all',
			store : store,
			mode : 'remote',
			valueField : 'id',
			displayField : 'text'
		})
		var p_manage = new Ext.FormPanel( {
			labelWidth : 100,
			labelAlign : "left",
			layout : "form",
			region : "center",
			frame : true,
			items : [ {
				title : '新增关注点',
				layout : 'form',
				xtype : 'fieldset',
				bodyStyle : 'padding: 10px 0 10px 0',
				collapsible : false,
				labelAlign : 'left',
				height : '100%',
				width : '100%',
				items : [ {
					xtype : "hidden",
					fieldLabel : "关 注 点 编 号 ",
					emptyText : '自动生成',
					disabled : true,
					id : 'pointID',
					anchor : "88%"
				}, {
					xtype : "textfield",
					fieldLabel : "关 注 点 编 码 ",
					allowBlank : false,
					id : 'pointCode',
					anchor : "88%",
					emptyText : '字母或下划线开头',
					regex : /^[A-Za-z_]+[A-Za-z0-9_]*$/
				}, {
					xtype : "textfield",
					fieldLabel : "关 注 点 名 称 ",
					emptyText : '请填写',
					blankText : '此项必填',
					allowBlank : false,
					anchor : "88%",
					id : 'pointName'
				}, {
					xtype : "textfield",
					fieldLabel : "关 注 点 描 述 ",
					emptyText : '请填写',
					blankText : '此项选填',
					allowBlank : true,
					anchor : "88%",
					id : 'pointDesc'
				}, {
					xtype : "hidden",
					fieldLabel : "所 属 环 节 ",
					anchor : "88%",
					id : 'linkID_hidden'
				}, [ comb_link ] ]
			} ]
		})
	}

	var win_add = new Ext.Window( {
		layout : 'fit',
		width : 400,
		height : 250,
		closeAction : 'close',
		plain : true,
		modal : true,
		layout : "border",
		tbar : [ '-', {
			text : "保存",
			handler : function() {
				var win_value = Ext.ComponentMgr.get("getwin").getValue();
				if (win_value == '' || win_value == '0') {
					saveForm_process_domain();
				} else if (win_value == '1') {
					saveForm_process();
				} else if (win_value == '2') {
					saveForm_process_lifecycle();
				} else if (win_value == '3') {
					saveForm_link();
				} else if (win_value == '4') {
					saveForm_point();
				}
			}
		}, '-', {
			text : "关闭",
			handler : function() {
				win_add.close();
			}
		}, {
			xtype : 'hidden',
			id : 'getwin'
		}, {
			xtype : 'hidden',
			id : 'first'
		}, '-' ],
		items : [ p_manage ]
	})
	win_add.show(this);

	// Ext.ComponentMgr.get("getwin").setValue(btn_value);
	Ext.ComponentMgr.get("getwin").setValue(deep);
	var treeid = Ext.ComponentMgr.get("get_tree_id").getValue();
	var treename = Ext.ComponentMgr.get("get_tree_name").getValue();
	var treefid = Ext.ComponentMgr.get("get_tree_fid").getValue();
	var treefname = Ext.ComponentMgr.get("get_tree_fname").getValue();
	var win_value = Ext.ComponentMgr.get("getwin").getValue();

	if (win_value == '1') {
		Ext.ComponentMgr.get("domainID").setValue(treename);
		Ext.ComponentMgr.get("domainID_hidden").setValue(treeid);
		Ext.ComponentMgr.get("first").setValue(treeid);
	}

	if (win_value == '2') {
		Ext.ComponentMgr.get("processID").setValue(treename);
		Ext.ComponentMgr.get("processID_hidden").setValue(treeid);
		Ext.ComponentMgr.get("first").setValue(treeid);
	}

	if (win_value == '3') {
		Ext.ComponentMgr.get("lifecycleID").setValue(treename);
		Ext.ComponentMgr.get("lifecycleID_hidden").setValue(treeid);
		Ext.ComponentMgr.get("first").setValue(treeid);
	}

	if (win_value == '4') {
		Ext.ComponentMgr.get("linkID").setValue(treename);
		Ext.ComponentMgr.get("linkID_hidden").setValue(treeid);
		Ext.ComponentMgr.get("first").setValue(treeid);
	}

	// =================================================================//

	function saveForm_process_domain() {
		formStore.Code = Ext.ComponentMgr.get("domainCode").getValue();
		formStore.Name = Ext.ComponentMgr.get("domainName").getValue();
		formStore.Desc = Ext.getCmp("domainDesc").getValue();
		formStore.parentID = 1;
		formStore.Win = "01";
		send_url();
	}
	function saveForm_process() {
		var treeid = Ext.ComponentMgr.get("get_tree_id").getValue();
		var treename = Ext.ComponentMgr.get("get_tree_name").getValue();
		formStore.Code = Ext.ComponentMgr.get("processCode").getValue();
		formStore.Name = Ext.ComponentMgr.get("processName").getValue();
		formStore.Desc = Ext.getCmp("processDesc").getValue();
		var domainID = Ext.ComponentMgr.get("domainID").getValue();
		if (isnumber_all(domainID)) {
			Ext.getCmp("domainID_hidden").setValue(
					Ext.ComponentMgr.get("first").getValue());
		} else {
			Ext.getCmp("domainID_hidden").setValue(domainID);
		}
		formStore.parentID = Ext.getCmp("domainID_hidden").getValue();
		formStore.Win = 1;
		send_url();
	}
	function saveForm_process_lifecycle() {
		var treeid = Ext.ComponentMgr.get("get_tree_id").getValue();
		var treename = Ext.ComponentMgr.get("get_tree_name").getValue();
		formStore.Code = Ext.ComponentMgr.get("lifecycleCode").getValue();
		formStore.Name = Ext.ComponentMgr.get("lifecycleName").getValue();
		formStore.Desc = Ext.getCmp("lifecycleDesc").getValue();
		var processID = Ext.ComponentMgr.get("processID").getValue();
		if (isnumber_all(processID)) {
			Ext.getCmp("processID_hidden").setValue(
					Ext.ComponentMgr.get("first").getValue());
		} else {
			Ext.getCmp("processID_hidden").setValue(processID);
		}
		formStore.parentID = Ext.getCmp("processID_hidden").getValue();
		formStore.Win = "10";
		send_url();
	}
	function saveForm_link() {
		var treeid = Ext.ComponentMgr.get("get_tree_id").getValue();
		var treename = Ext.ComponentMgr.get("get_tree_name").getValue();
		formStore.Code = Ext.ComponentMgr.get("linkcode").getValue();
		formStore.Name = Ext.ComponentMgr.get("linkname").getValue();
		formStore.Desc = Ext.ComponentMgr.get("linkDesc").getValue();
		var lifecycle = Ext.ComponentMgr.get("lifecycleID").getValue();
		if (isnumber_all(lifecycle)) {
			Ext.getCmp("lifecycleID_hidden").setValue(
					Ext.ComponentMgr.get("first").getValue());
		} else {
			Ext.getCmp("lifecycleID_hidden").setValue(lifecycle);
		}
		formStore.parentID = Ext.getCmp("lifecycleID_hidden").getValue();
		formStore.Win = 3;
		send_url();
	}
	function saveForm_point() {
		var treeid = Ext.ComponentMgr.get("get_tree_id").getValue();
		var treename = Ext.ComponentMgr.get("get_tree_name").getValue();
		formStore.Code = Ext.ComponentMgr.get("pointCode").getValue();
		formStore.Name = Ext.ComponentMgr.get("pointName").getValue();
		formStore.Desc = Ext.getCmp("pointDesc").getValue();
		var link = Ext.getCmp("linkID").getValue();
		if (isnumber_all(link)) {
			Ext.getCmp("linkID_hidden").setValue(
					Ext.ComponentMgr.get("first").getValue());
		} else {
			Ext.getCmp("linkID_hidden").setValue(link);
		}
		formStore.parentID = Ext.getCmp("linkID_hidden").getValue();
		formStore.Win = 4;
		send_url();
	}
	// 判断输入为大写字母和下划线
	function isDigit(s) {
		var patrn = /^[A-Za-z_]+[A-Za-z0-9_]*$/;
		if (patrn.exec(s))
			return false
		return true
	}

	// 判断输入为0-9的正整数
	function isnumber(s) {
		var patrn = /^[0-9]*$/;
		if (patrn.exec(s))
			return false
		return true
	}

	// 验证process_domain_num的字符
	function isprocess_domain_num(s) {
		var patrn = /^domain_[1-9]+$/;
		if (patrn.exec(s)) {
			return true
		}
		return false
	}
	// 验证process_num的字符
	function isprocess_num(s) {
		var patrn = /^pro_[1-9]+$/;
		if (patrn.exec(s)) {
			return true
		}
		return false
	}
	// 验证process_lifecycle_num的字符
	function isprocess_lifecycle_num(s) {
		var patrn = /^life_[1-9]+$/;
		if (patrn.exec(s)) {
			return true
		}
		return false
	}

	// 验证link_num的字符
	function islink_num(s) {
		var patrn = /^link_[1-9]+$/;
		if (patrn.exec(s))
			return true
		return false
	}

	// 验证point_num的字符
	function ispoint_num(s) {
		var patrn = /^point_[1-9]+$/;
		if (patrn.exec(s))
			return true
		return false
	}

	// 判断输入为正整数
	function isnumber_all(s) {
		var patrn = /^[0-9]*[1-9][0-9]*$/;
		if (patrn.exec(s))
			return false
		return true
	}
	function send_url() {
		var saveUrl_manage = "";
		saveUrl_manage = '?className=cn.com.jsepc.rep.process.process_manage';
		saveUrl_manage += '&methodName=add_manage';
		saveUrl_manage += '&paramCount=0';
		saveUrl_manage = basePath + 'JarpListener' + saveUrl_manage;

		if (formStore.Code == "") {
			Ext.Msg.alert('提示', '编码不能为空！');
		} else if (isDigit(formStore.Code)) {
			Ext.Msg.alert('提示', '编码只能为大写字母、数字和下划线格式，并且只能以字母和下划线开头！');
		} else if ((formStore.Code).length > 20) {
			Ext.Msg.alert('提示', '编码超过限定长度(最大长度为20个字符)！');
		} else if (formStore.Name == "") {
			Ext.Msg.alert('提示', '名称不能为空！');
		} else if ((formStore.Name).length > 32) {
			Ext.Msg.alert('提示', '名称超过限定长度(最大长度为32个字符)！');
		} else if ((formStore.Desc).length > 500) {
			Ext.Msg.alert('提示', '描述不能超过500个汉字');
		} else if (formStore.parentID == "" && formStore.parentID == 0) {
			Ext.Msg.alert('提示', '所属不能为空');
		} else {
			http_return = getXMLHttpRequest();
			http_return.onreadystatechange = Save_return;
			http_return.open("POST", saveUrl_manage, true);
			http_return.send(Ext.util.JSON.encode(formStore));
		}
	}

	// 返回值 处理
	function Save_return() {
		if (http_return.readyState == 4) {
			if (http_return.status == 200) {
				ret = http_return.responseText;
				if (ret == 'haven') {
					Ext.Msg.alert('提示', '数据库已存在此编码 ，请重新填写');
				} else if (ret == 'haven1') {
					Ext.Msg.alert('提示', '数据库已存在此名称 ，请重新填写');
				} else if (ret == 'ok') {
					win_add.close();
					Ext.Msg.alert('提示', '添加成功！');
					grid_reroad();
				} else {
					Ext.MessageBox.show( {
						title : '提 示',
						msg : ' 添加失败 ，请重新填写'
					});
					setTimeout("window.location.reload()", 1500);
				}
			}
		}
	}
	// 刷新表格
	function grid_reroad() {
		var deep = Ext.ComponentMgr.get("get_tree_deep").getValue();
		var tree = Ext.ComponentMgr.get("tree_mangae");

		var grid = Ext.ComponentMgr.get("grid_process_domain");
		grid.store.reload();
		refresh();

	}
	function refresh() {
		var tree = Ext.ComponentMgr.get("tree_mangae");
		var node = tree.getSelectionModel().getSelectedNode();
		if (node == null) {
			tree.root.reload();
		} else {
			var nodeid = Ext.ComponentMgr.get("get_tree_id").getValue();
			var path = node.getPath('id');
			tree.root.reload();
			tree.selectPath(path, "id");
		}
	}
}